home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 January / maximum-cd-1999-01.iso / Benchmarks / 12 Step / MusicMatch Jukebox / mmsetup.EXE / data1.cab / Help_Files / WebHelp.cab / hhapplet / IndexSecondaryDialog.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-03-27  |  3.9 KB  |  143 lines

  1. package hhapplet;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.BorderLayout;
  5. import java.awt.Button;
  6. import java.awt.Color;
  7. import java.awt.Component;
  8. import java.awt.Container;
  9. import java.awt.Dimension;
  10. import java.awt.Event;
  11. import java.awt.Font;
  12. import java.awt.Frame;
  13. import java.awt.Label;
  14. import java.awt.List;
  15. import java.awt.Panel;
  16. import java.awt.Point;
  17. import java.awt.Toolkit;
  18. import java.net.MalformedURLException;
  19. import java.util.Vector;
  20.  
  21. public class IndexSecondaryDialog extends Frame {
  22.    protected Button m_btnDisplay = new Button("Display");
  23.    protected Button m_btnCancel = new Button("Cancel");
  24.    protected List m_list = new List();
  25.    protected Applet m_applet;
  26.    protected Vector m_vEntries;
  27.    protected DialogDoneTarget m_ddtDone;
  28.    private boolean m_bIsIE3;
  29.    private Point m_pntPosition;
  30.  
  31.    public boolean gotFocus(Event var1, Object var2) {
  32.       if (var1.target == this) {
  33.          this.m_list.requestFocus();
  34.          return true;
  35.       } else {
  36.          return super.gotFocus(var1, var2);
  37.       }
  38.    }
  39.  
  40.    public IndexSecondaryDialog(Applet var1, Vector var2, DialogDoneTarget var3) {
  41.       super("Topics Found");
  42.       this.m_applet = var1;
  43.       this.m_vEntries = var2;
  44.       this.m_ddtDone = var3;
  45.       if (System.getProperty("java.vendor").startsWith("Microsoft") && System.getProperty("java.version").startsWith("1.0")) {
  46.          this.m_bIsIE3 = true;
  47.       }
  48.  
  49.       int var4 = WebHelp.GetFontSize();
  50.       this.m_list.setFont(new Font(WebHelp.GetFontName(), 0, var4));
  51.  
  52.       for(int var5 = 0; var5 < this.m_vEntries.size(); ++var5) {
  53.          this.m_list.addItem(((IndexSecondaryEntry)this.m_vEntries.elementAt(var5)).name);
  54.       }
  55.  
  56.       this.m_list.select(0);
  57.       Panel var11 = new Panel();
  58.       ((Container)var11).add(this.m_btnDisplay);
  59.       ((Container)var11).add(this.m_btnCancel);
  60.       ((Container)this).setLayout(new BorderLayout(5, 5));
  61.       this.m_list.setBackground(Color.white);
  62.       ((Component)this).setBackground(Color.lightGray);
  63.       short var6 = 300;
  64.       short var7 = 240;
  65.       ((Component)this).resize(var6, var7);
  66.       ((Container)this).add("North", new Label("Click a topic, then click Display."));
  67.       ((Container)this).add("South", var11);
  68.       ((Container)this).add("Center", this.m_list);
  69.       Dimension var8 = Toolkit.getDefaultToolkit().getScreenSize();
  70.       int var9 = var8.width / 2 - var6 / 2;
  71.       int var10 = var8.height / 2 - var7 / 2;
  72.       this.m_pntPosition = new Point(var9, var10);
  73.       ((Component)this).move(var9, var10);
  74.       ((Frame)this).setResizable(false);
  75.    }
  76.  
  77.    protected void gotoSelectedIndex() {
  78.       int var1 = this.m_list.getSelectedIndex();
  79.       if (var1 != -1) {
  80.          try {
  81.             IndexSecondaryEntry var2 = (IndexSecondaryEntry)this.m_vEntries.elementAt(var1);
  82.             if (var2.frame != null) {
  83.                this.m_applet.getAppletContext().showDocument(URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var2.local, var2.url), var2.frame);
  84.             } else {
  85.                this.m_applet.getAppletContext().showDocument(URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var2.local, var2.url), "_self");
  86.             }
  87.          } catch (MalformedURLException var3) {
  88.          }
  89.  
  90.          this.closeDialog();
  91.          ((Frame)this).dispose();
  92.       }
  93.  
  94.    }
  95.  
  96.    public void show() {
  97.       if (this.m_bIsIE3) {
  98.          Dimension var1 = ((Component)this).size();
  99.          ((Component)this).reshape(this.m_pntPosition.x, this.m_pntPosition.y, var1.width, var1.height);
  100.          super.show();
  101.          ((Component)this).reshape(this.m_pntPosition.x, this.m_pntPosition.y, var1.width, var1.height);
  102.       } else {
  103.          super.show();
  104.       }
  105.  
  106.       this.m_list.requestFocus();
  107.    }
  108.  
  109.    public boolean action(Event var1, Object var2) {
  110.       if (var1.target != this.m_btnDisplay && var1.target != this.m_list) {
  111.          if (var1.target == this.m_btnCancel) {
  112.             this.closeDialog();
  113.             return true;
  114.          } else {
  115.             return false;
  116.          }
  117.       } else {
  118.          this.gotoSelectedIndex();
  119.          return true;
  120.       }
  121.    }
  122.  
  123.    protected void closeDialog() {
  124.       ((Frame)this).dispose();
  125.       if (this.m_ddtDone != null) {
  126.          this.m_ddtDone.dialogDone();
  127.       }
  128.  
  129.    }
  130.  
  131.    public boolean handleEvent(Event var1) {
  132.       if (var1.id == 201) {
  133.          this.closeDialog();
  134.          ((Frame)this).dispose();
  135.       } else if (var1.target == this.m_list && var1.key == 10 && var1.id == 402) {
  136.          this.gotoSelectedIndex();
  137.          return true;
  138.       }
  139.  
  140.       return super.handleEvent(var1);
  141.    }
  142. }
  143.